/*----------------------------------------\ | Centeralize a text string in the SAS output window; | |-------------------------------------------| |--------------------------------------------------------------------| |---------------------------| | A string or a quoted string will be needed; | |--------------------------------| |--------------------------------------------------------------------| |---------------------------------------| | Example: title %center(%initcaps("this is a text")); | | Usage: %center(string); | \----------------------------------------*/ %macro center/parmbuff; /*--------------------------------------------\ | Copy Right: Duo Zhou; | | Created: 9-16-2001 8:25pm; | | Purpose: Centralize a string of text; | \--------------------------------------------*/ %local string _centertexttxt1_ _centertexttxt2_ _centertext_ _centerlinesize_ _centerindent_ _centernewtext_; %let _centerlinesize_ = %SYSFUNC(GETOPTION(linesize)); %if (%length(%nrbquote(&syspbuff)) gt 2) %then %do; %let _centertexttxt1_=%nrbquote(%substr(%nrbquote(&syspbuff), 2, %eval(%length(%nrbquote(&syspbuff))-2))); %let _centertexttxt2_=%nrbquote(%sysfunc(dequote(%nrbquote(&_centertexttxt1_)))); %if (%index(%nrbquote(&_centertexttxt1_),%nrbquote(&_centertexttxt2_)) >1) %then %let _centernumofspace_ = %EVAL(&_centerlinesize_ - %LENGTH(%nrbquote(&_centertexttxt2_))); %else %let _centernumofspace_ = %EVAL(&_centerlinesize_ - %LENGTH(%nrbquote(&_centertexttxt1_))); %LET _centerindent_ = %EVAL(&_centernumofspace_/2); %let _centernewtext_=; %do _i_=1 %to &_centerindent_; %let _centernewtext_=&_centernewtext_%str( ); %end; %if (%index(%nrbquote(&_centertexttxt1_),%nrbquote(&_centertexttxt2_)) >1) %then %do; %if (%index(%nrbquote(&_centertexttxt2_),%str(%"))) %then %let _centernewtext_=%nrbquote(%sysfunc(tranwrd(%nrbquote(&_centertexttxt2_),%str(%"),%str(%')))); %let _centernewtext_=&_centernewtext_"&_centertexttxt2_"; %end; %else %let _centernewtext_=%nrbquote(&_centernewtext_.&_centertexttxt1_); &_centernewtext_ %end; %MEND center;